# Copyright 2010 Mikko Rantanen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from rest import Resource

# Initialize cookies. This step is a hack due to IIS not
# replying with cookie information for our REST calls.
root = Resource('http://dev.jubjubnest.net/mfwa/')
root.init_cookies()

rest = root.resource('rest')

# Get the session resource, which is located in /mfwa/rest/session
session = rest.resource('session')

# Put the username and password into the session, MFWA replies
# with a list of vaults.
vaults = session.put({'Username':'test', 'Password':'test'})

# Grab the guid from the first vault and put it into the 'vault'
# subresource of the session.
guid = vaults[0]['GUID']
session.resource('vault').put(guid)
